/*
 * @Author: intellectual seeker 3336339701@qq.com
 * @Date: 2024-12-20 13:19:04
 * @LastEditors: intellectual seeker 3336339701@qq.com
 * @LastEditTime: 2024-12-20 13:20:06
 * @FilePath: /linux-learning/code/lesson24/file_fd/test.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

int main()
{
    //文件创建时的默认权限
    umask(0);
	int fd = open("log.txt",O_WRONLY | O_CREAT | O_TRUNC, 0664);
	dup2(fd, 1);
    printf("%d\n", fd);
	char buf[1024] = {0};
	scanf("%s", buf);
	printf("%s\n", buf);

	return 0;
}
